package com.seocoo.worker.user.account.model;

import com.seocoo.worker.user.login.model.ReqSMS;
import com.seocoo.worker.user.account.model.req.ReqBundCard;
import com.seocoo.worker.user.account.model.req.ReqCard;
import com.seocoo.worker.user.account.model.req.ReqUnbundCard;
import com.sfh.lib.mvvm.BaseViewModel;

public class CardModel  extends BaseViewModel {
    /***
     * 我的银行卡
     */
    public void queryCard(){
        this.execute(true, new ReqCard(), eBankCarBaseRsp -> {
            if(eBankCarBaseRsp.success()){
                setValue("onBankCar",eBankCarBaseRsp.getData());
            }
        });
    }

    /***
     * 解绑银行卡
     */
    public void unbundCard(){
        this.execute(false, new ReqUnbundCard(), eBankCarBaseRsp -> {
            if(eBankCarBaseRsp.success()){
                setValue("onUnBundCardSuccess");
            }else{
                showDialogToast(eBankCarBaseRsp.getMsg());
            }
        });
    }

    /***
     * 绑银行卡
     */
    public void bundCard(ReqBundCard req){
        this.execute(false, req, eBankCarBaseRsp -> {
            if(eBankCarBaseRsp.success()){
                setValue("onBundCardSuccess");
            }else{
                showDialogToast(eBankCarBaseRsp.getMsg());
            }
        });
    }

    /***
     * 发送短信
     * @param req
     */
    public void sendSMS(ReqSMS req) {

        this.execute(false, req, result -> {
            if (result.success()){
                showToast("验证码发送成功！");
                setValue("onSendCodeSuccess");
            }else {
                showDialogToast(result.getMsg());
            }
        });
    }
}
